# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=dirsearch
pkgver=2521.70a7635
pkgrel=1
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner')
pkgdesc='HTTP(S) directory/file brute forcer.'
arch=('any')
url='https://github.com/maurosoria/dirsearch'
license=('GPL2')
depends=('python' 'python-pysocks' 'python-jinja' 'python-defusedxml'
         'python-pyopenssl' 'python-requests' 'python-requests-ntlm'
         'python-colorama' 'python-ntlm-auth' 'python-beautifulsoup4'
         'python-mysql-connector' 'python-psycopg' 'python-defusedcsv'
         'python-requests-toolbelt' 'python-setuptools' 'python-httpx'
         'python-httpx-ntlm')
makedepends=('git')
source=("git+https://github.com/maurosoria/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  #sed -i '/save-logs-home/s/^# //g' default.conf
  sed -i 's/pyparsing>=3.0.6/pyparsing>=3.0.4/' requirements.txt
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/$pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

